<template>
  <div id="wrap">
    <h1>defineEmits带类型声明</h1>
    <!-- 子组件SonDemo12 -->
    <SonDemo12 @submit="submitHandler"></SonDemo12>

    <!-- 子组件SonDemo13 -->
    <SonDemo13
    @edit-user="editUserHandler"
    @edit="editrHandler"
    @update="updateHandler"
    @change="changeHandler"
    ></SonDemo13>
  </div>
</template>

<script lang="ts">
export default {
  name: 'dayStuDemo42.vue',
};
</script>

<script lang="ts" setup>
import { type Iuser } from './components/SonDemo13.vue';
import SonDemo12 from './components/SonDemo12.vue';
import SonDemo13 from './components/SonDemo13.vue';
// 子组件SonDemo12
const submitHandler = (payload: { email: string; password: string }) => {
  console.log('submitHandler');
  if (payload.email == '222' && payload.password == '333') {
    alert('账号密码验证正确');
  } else {
    alert('错误');
  }
};

//
const editUserHandler = (user: Iuser) => {
  console.log(user, 'editUserHandler')
}
const editrHandler = (val1:string,val2:number) => {
  console.log(val1,val2)
}
const updateHandler = (val:string) => {
  console.log(val)
}
const changeHandler = (id:number) => {
  console.log(id)
}
</script>
